package com.cardbaobao.cardbabyclient.ui.adapter;

import android.content.Context;
import android.view.View;

import com.cardbaobao.cardbabyclient.R;
import com.cardbaobao.cardbabyclient.ui.adapter.base.CommonRecyclerAdapter;
import com.cardbaobao.cardbabyclient.ui.adapter.base.CommonRecyclerHolder;
import com.cardbaobao.cardbabyclient.callback.RecycleItemClickedCallback;
import com.cardbaobao.cardbabyclient.model.ImageResAndText;
/**
 * Created by Jiangzx on 11:43.
 */

public class DiscoverBusinessAdapter extends CommonRecyclerAdapter<ImageResAndText>{
    public DiscoverBusinessAdapter(Context context){
        super(context,null,R.layout.item_image_text_padding_30dp_no_margin);
    }

    @Override
    public void convert(final CommonRecyclerHolder holder, ImageResAndText item) {
        holder.setTextViewText(R.id.tv,item.getText());
        holder.setImageRes(R.id.civ,item.getRes());
        holder.getView(R.id.ll_root).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                if(clickedCallback!=null){
                    clickedCallback.onRecycleItemClicked(holder.position);
                }
            }
        });
    }

    private RecycleItemClickedCallback clickedCallback;

    public void setClickedCallback(RecycleItemClickedCallback clickedCallback){
        this.clickedCallback=clickedCallback;
    }
}
